package ru.study.thinkin.chapter11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;


public abstract class Pet {
	public int id = new Random().nextInt(100);
	public String name;
	public Pet(String name) {
		this.name=name;
	}
	public Pet() {
		this.name="Noname";
	}	
	
	@Override
	public String toString() {
		return getClass().getSimpleName();
	}
}

class Hamster extends Pet{
	public Hamster(String name) {
		super(name);
	}
	public Hamster () {
		
	}
}

class Cat extends Pet{
	public Cat(String name) {
		super(name);
	} 
	public Cat(){
		
	}
}
class Dog extends Pet{

	public Dog(String name) {
		super(name);		
	}
	public Dog() {
				
	}
}
class Rat extends Pet{

	public Rat(String name) {
		super(name);
	}
	public Rat() {
	
	}
}
class Mutt extends Pet{

	public Mutt(String name) {
		super(name);
	}
	public Mutt() {
	
	}
}

class Pets {
	private static Pet getRandomPet() {
		int i = new Random().nextInt(4);
		Pet pet = new Rat(); 
		if (i==0) {
			pet = new Cat();
		} else if (i==1) {
			pet = new Dog();
		} else if (i==2) {
			pet = new Mutt();
		}
		return pet;
	}
	
	static ArrayList<Pet> arrayList(int j) {
		Pet[] arr = new Pet[j];		
		
		for (int i = 0;i<arr.length;i++) {
			arr[i]= getRandomPet();
		}		
		ArrayList list = new ArrayList<Pet>(Arrays.asList(arr));
		
		return list;
	}
}